#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    {
        cout << "Point(int = 0, int = 0)" << endl;
    }

    //编译器会自动生成拷贝构造函数
    Point(const Point &rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        cout << "Point(const Point &)" << endl;
    }

    void print()
    {
        cout << "(" << _ix 
             << ", " << _iy
             << ")" << endl;
    }

    ~Point()
    {
        cout << "~Point()" << endl;
    }

private:
    int _ix;
    int _iy;
};

void test()
{
    Point pt;
    cout << "pt = ";
    pt.print();

    cout << endl;
    Point pt2(3, 4);
    cout << "pt2 = ";
    pt2.print();
}

void test2()
{
    int a = 10;
    int b = a;
    cout << "a = " << a << endl
         << "b = " << b << endl;

    cout << endl;
    Point pt1(1, 2);
    cout << "pt1 = ";
    pt1.print();

    cout << endl;
    Point pt2 = pt1;//创建对象会调用构造函数
    cout << "pt2 = ";
    pt2.print();
}


int main(int argc, char **argv)
{
    cout << "begin test..." << endl;
    test2();
    cout << "finish test..." << endl;
    return 0;
}

